/*   1:    */ package com.atomikos.icatch.imp;
/*   2:    */ 
/*   3:    */ import com.atomikos.icatch.CompositeCoordinator;
/*   4:    */ import com.atomikos.icatch.CompositeTransaction;
/*   5:    */ import com.atomikos.icatch.Extent;
/*   6:    */ import com.atomikos.icatch.HeurHazardException;
/*   7:    */ import com.atomikos.icatch.HeurMixedException;
/*   8:    */ import com.atomikos.icatch.HeurRollbackException;
/*   9:    */ import com.atomikos.icatch.HeuristicMessage;
/*  10:    */ import com.atomikos.icatch.Participant;
/*  11:    */ import com.atomikos.icatch.RecoveryCoordinator;
/*  12:    */ import com.atomikos.icatch.RollbackException;
/*  13:    */ import com.atomikos.icatch.SubTxAwareParticipant;
/*  14:    */ import com.atomikos.icatch.Synchronization;
/*  15:    */ import com.atomikos.icatch.SysException;
/*  16:    */ import com.atomikos.icatch.TransactionControl;
/*  17:    */ import java.io.Serializable;
/*  18:    */ import java.util.Properties;
/*  19:    */ import java.util.Stack;
/*  20:    */ 
/*  21:    */ public abstract class AbstractCompositeTransaction
/*  22:    */   implements CompositeTransaction, Serializable
/*  23:    */ {
/*  24:    */   private static final long serialVersionUID = 3522422565305065464L;
/*  25:    */   protected Stack lineage_;
/*  26:    */   protected String tid_;
/*  27:    */   protected boolean serial_;
/*  28:    */   protected HeuristicMessage tag_;
/*  29:    */   protected Properties properties_;
/*  30:    */   
/*  31:    */   private static void fail()
/*  32:    */     throws UnsupportedOperationException
/*  33:    */   {
/*  34: 64 */     throw new UnsupportedOperationException("This functionality is not available for this instance");
/*  35:    */   }
/*  36:    */   
/*  37:    */   public AbstractCompositeTransaction() {}
/*  38:    */   
/*  39:    */   public AbstractCompositeTransaction(String tid, Stack lineage, boolean serial)
/*  40:    */   {
/*  41: 95 */     this.tid_ = tid;
/*  42: 96 */     this.lineage_ = lineage;
/*  43: 97 */     if (this.lineage_ == null)
/*  44:    */     {
/*  45: 98 */       this.lineage_ = new Stack();
/*  46: 99 */       this.properties_ = new Properties();
/*  47:    */     }
/*  48:102 */     else if (!this.lineage_.empty())
/*  49:    */     {
/*  50:103 */       CompositeTransaction parent = (CompositeTransaction)this.lineage_.peek();
/*  51:104 */       this.properties_ = parent.getProperties();
/*  52:    */     }
/*  53:107 */     if (this.properties_ == null) {
/*  54:107 */       this.properties_ = new Properties();
/*  55:    */     }
/*  56:108 */     this.serial_ = serial;
/*  57:    */   }
/*  58:    */   
/*  59:    */   public String getTid()
/*  60:    */   {
/*  61:118 */     return this.tid_;
/*  62:    */   }
/*  63:    */   
/*  64:    */   public void setTag(HeuristicMessage tag)
/*  65:    */   {
/*  66:127 */     this.tag_ = tag;
/*  67:    */   }
/*  68:    */   
/*  69:    */   public boolean isSerial()
/*  70:    */   {
/*  71:136 */     return this.serial_;
/*  72:    */   }
/*  73:    */   
/*  74:    */   public boolean isLocal()
/*  75:    */   {
/*  76:148 */     return false;
/*  77:    */   }
/*  78:    */   
/*  79:    */   public TransactionControl getTransactionControl()
/*  80:    */     throws UnsupportedOperationException
/*  81:    */   {
/*  82:159 */     return null;
/*  83:    */   }
/*  84:    */   
/*  85:    */   public RecoveryCoordinator addParticipant(Participant participant)
/*  86:    */     throws SysException, IllegalStateException
/*  87:    */   {
/*  88:170 */     throw new UnsupportedOperationException("addParticipant");
/*  89:    */   }
/*  90:    */   
/*  91:    */   public void registerSynchronization(Synchronization sync)
/*  92:    */     throws IllegalStateException, UnsupportedOperationException, SysException
/*  93:    */   {
/*  94:180 */     throw new UnsupportedOperationException("registerSynchronization");
/*  95:    */   }
/*  96:    */   
/*  97:    */   public Stack getLineage()
/*  98:    */   {
/*  99:189 */     return (Stack)this.lineage_.clone();
/* 100:    */   }
/* 101:    */   
/* 102:    */   public boolean isRoot()
/* 103:    */   {
/* 104:198 */     return (this.lineage_ == null) || (this.lineage_.size() == 0);
/* 105:    */   }
/* 106:    */   
/* 107:    */   public boolean isAncestorOf(CompositeTransaction ct)
/* 108:    */   {
/* 109:208 */     return ct.isDescendantOf(this);
/* 110:    */   }
/* 111:    */   
/* 112:    */   public boolean isDescendantOf(CompositeTransaction ct)
/* 113:    */   {
/* 114:217 */     CompositeTransaction parent = null;
/* 115:218 */     if ((this.lineage_ != null) && (!this.lineage_.empty())) {
/* 116:219 */       parent = (CompositeTransaction)this.lineage_.peek();
/* 117:    */     }
/* 118:221 */     return (isSameTransaction(ct)) || ((parent != null) && (parent.isDescendantOf(ct)));
/* 119:    */   }
/* 120:    */   
/* 121:    */   public boolean isRelatedTransaction(CompositeTransaction ct)
/* 122:    */   {
/* 123:231 */     Stack lineage = null;
/* 124:232 */     if (this.lineage_ == null) {
/* 125:233 */       lineage = new Stack();
/* 126:    */     } else {
/* 127:235 */       lineage = (Stack)this.lineage_.clone();
/* 128:    */     }
/* 129:237 */     if (lineage.empty()) {
/* 130:238 */       return isAncestorOf(ct);
/* 131:    */     }
/* 132:240 */     CompositeTransaction root = null;
/* 133:241 */     while (!lineage.empty()) {
/* 134:242 */       root = (CompositeTransaction)lineage.pop();
/* 135:    */     }
/* 136:243 */     return root.isAncestorOf(ct);
/* 137:    */   }
/* 138:    */   
/* 139:    */   public boolean isSameTransaction(CompositeTransaction ct)
/* 140:    */   {
/* 141:252 */     return equals(ct);
/* 142:    */   }
/* 143:    */   
/* 144:    */   public int hashCode()
/* 145:    */   {
/* 146:269 */     int ret = 0;
/* 147:271 */     if (this.tid_ == null) {
/* 148:272 */       ret = super.hashCode();
/* 149:    */     } else {
/* 150:274 */       ret = getTid().hashCode();
/* 151:    */     }
/* 152:277 */     return ret;
/* 153:    */   }
/* 154:    */   
/* 155:    */   public boolean equals(Object obj)
/* 156:    */   {
/* 157:281 */     if (this == obj) {
/* 158:282 */       return true;
/* 159:    */     }
/* 160:283 */     if (obj == null) {
/* 161:284 */       return false;
/* 162:    */     }
/* 163:285 */     if (!(obj instanceof AbstractCompositeTransaction)) {
/* 164:286 */       return false;
/* 165:    */     }
/* 166:287 */     AbstractCompositeTransaction other = (AbstractCompositeTransaction)obj;
/* 167:288 */     if (this.tid_ == null)
/* 168:    */     {
/* 169:289 */       if (other.tid_ != null) {
/* 170:290 */         return false;
/* 171:    */       }
/* 172:    */     }
/* 173:291 */     else if (!this.tid_.equals(other.tid_)) {
/* 174:292 */       return false;
/* 175:    */     }
/* 176:293 */     return true;
/* 177:    */   }
/* 178:    */   
/* 179:    */   public CompositeCoordinator getCompositeCoordinator()
/* 180:    */     throws SysException, UnsupportedOperationException
/* 181:    */   {
/* 182:303 */     throw new UnsupportedOperationException("Not implemented: class for testing ");
/* 183:    */   }
/* 184:    */   
/* 185:    */   public void addSubTxAwareParticipant(SubTxAwareParticipant subtxaware)
/* 186:    */     throws SysException, UnsupportedOperationException, IllegalStateException
/* 187:    */   {
/* 188:314 */     throw new UnsupportedOperationException("addSubTxAwareParticipant");
/* 189:    */   }
/* 190:    */   
/* 191:    */   public CompositeTransaction createSubTransaction()
/* 192:    */     throws SysException, IllegalStateException
/* 193:    */   {
/* 194:323 */     fail();
/* 195:324 */     return null;
/* 196:    */   }
/* 197:    */   
/* 198:    */   public void setSerial()
/* 199:    */     throws IllegalStateException, SysException
/* 200:    */   {}
/* 201:    */   
/* 202:    */   public int getLocalSubTxCount()
/* 203:    */   {
/* 204:343 */     return 0;
/* 205:    */   }
/* 206:    */   
/* 207:    */   public Extent getExtent()
/* 208:    */   {
/* 209:351 */     fail();
/* 210:352 */     return null;
/* 211:    */   }
/* 212:    */   
/* 213:    */   public long getTimeout()
/* 214:    */   {
/* 215:360 */     fail();
/* 216:361 */     return 0L;
/* 217:    */   }
/* 218:    */   
/* 219:    */   public void setRollbackOnly() {}
/* 220:    */   
/* 221:    */   public void commit()
/* 222:    */     throws HeurRollbackException, HeurMixedException, HeurHazardException, SysException, SecurityException, RollbackException
/* 223:    */   {}
/* 224:    */   
/* 225:    */   public void rollback()
/* 226:    */     throws IllegalStateException, SysException
/* 227:    */   {}
/* 228:    */   
/* 229:    */   public void setProperty(String name, String value)
/* 230:    */   {
/* 231:399 */     if (getProperty(name) == null) {
/* 232:400 */       this.properties_.setProperty(name, value);
/* 233:    */     }
/* 234:    */   }
/* 235:    */   
/* 236:    */   public String getProperty(String name)
/* 237:    */   {
/* 238:405 */     return this.properties_.getProperty(name);
/* 239:    */   }
/* 240:    */   
/* 241:    */   public Properties getProperties()
/* 242:    */   {
/* 243:410 */     return (Properties)this.properties_.clone();
/* 244:    */   }
/* 245:    */   
/* 246:    */   public Object getState()
/* 247:    */   {
/* 248:429 */     throw new UnsupportedOperationException("getState");
/* 249:    */   }
/* 250:    */ }


/* Location:           C:\myfile\mysoft\apache-maven-3.5.0-bin\apache-maven-3.5.0\myrep\com\atomikos\transactions\3.7.0\transactions-3.7.0.jar
 * Qualified Name:     com.atomikos.icatch.imp.AbstractCompositeTransaction
 * JD-Core Version:    0.7.0.1
 */